<?php

namespace app\api\model;

use think\Model;

class ProductStock extends Model
{
    protected $table = 'jxc_product_stock';

    /**
     * @return \think\model\relation\BelongsTo
     */
    public function product()
    {
        return $this->belongsTo(Product::class, 'product_id');
    }

    // 可用库存=待入库库存+已入库库存
    public function getAvStockAttr($value, $data)
    {
        return $data['stock'] + $data['put_in'];
    }
}
